#include <stdio.h>
#include "main.h"
#include "g.h"
#include "mytime.h"

void TIM_Configuration_sim(void)
{
	TIM6->CTRL1 = 0x01;
	TIM6->CTRL2 = 0;
	TIM6->DINTEN = 0x01;
	TIM6->STS = 0x01;
	TIM6->CNT = 0;
	TIM6->AR =0xbb7f; //0xbb7f;
}

void TIM_PWM_init_sim(void)
{
	TIM3->CTRL1 = 0x01;
	
	TIM3->STS = 0x1f;
	
	TIM3->CCMOD2 = 0x6800;
	TIM3->CCEN = 0x3000;
	TIM3->CNT = 0x01da;
	TIM3->PSC = 0x03;
	TIM3->AR = 0x05db;
	
}

INTStatus TIM_GetIntStatus(TIM_Module* TIMx, uint32_t TIM_IT)
{
    INTStatus bitstatus = RESET;
    uint32_t itstatus = 0x0, itenable = 0x0;
    /* Check the parameters */
    assert_param(IsTimAllModule(TIMx));
    assert_param(IsTimGetInt(TIM_IT));

    itstatus = TIMx->STS & TIM_IT;

    itenable = TIMx->DINTEN & TIM_IT;
    if ((itstatus != (uint32_t)RESET) && (itenable != (uint32_t)RESET))
    {
        bitstatus = SET;
    }
    else
    {
        bitstatus = RESET;
    }
    return bitstatus;
}

void TIM_ClrIntPendingBit(TIM_Module* TIMx, uint32_t TIM_IT)
{
    /* Check the parameters */
    assert_param(IsTimAllModule(TIMx));
    assert_param(IsTimInt(TIM_IT));
    /* Clear the IT pending Bit */
    TIMx->STS = (uint32_t)~TIM_IT;
}